package com.itcast.homework04.work11;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

/*

键盘录入出生年月日, 格式如(1990-1-1), 计算至今活了多少天?
*/
public class Test {
    public static void main(String[] args) throws ParseException {
        Scanner sc=new Scanner(System.in);
        System.out.println("请你输入你的出生年月日, 格式如(1990-1-1)：");
        String birthday = sc.next();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = sdf.parse(birthday);
        long birTime = parse.getTime();
        Date date=new Date();
        long nowDate = date.getTime();
        long lifeDay = nowDate - birTime;
        long l = lifeDay / 1000 / 60 / 60 / 24;
        System.out.println("你活了："+l+"天了！");
    }
}
